home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / tsemac.zip / ALIGN.S next >
Text File  |  1993-04-08  |  2KB  |  63 lines

  1. /************************************************************************
  2.   Author:  SemWare (Sammy Mitchell)
  3.   Date:    April 8, 1993
  4.  
  5.   Description:
  6.  
  7.   A couple of macros to shift text, and then move the cursor to the next
  8.   line.
  9.  
  10.   Usage notes:
  11.  
  12.   To use, add these macros to your TSE.S file, and key assignments to
  13.   your TSE.KEY file, and re-bind the editor using the -b switch of sc.
  14.  
  15.   Example key assignments might be:
  16.  
  17.   <f11>         Align()
  18.   <shift f11>   AlignAtCursor()
  19.  
  20.   Alternatively, add the key assignments to this file, and load the
  21.   macro (as an external macro) as needed via the LoadMacro command
  22.   (<ctrl f10><L> or 'menu->macro->load')
  23.  ************************************************************************/
  24.  
  25. // QEdit-type align command
  26. // Align the current line with the indentation of a previous line.
  27. // Would be _much_ simpler if we didn't have to account for hard tabs!
  28. // After aligning the current line, the cursor moves to the next line.
  29. proc Align()
  30.     string text[128]
  31.     integer p = CurrPos()
  32.  
  33.     PushPosition()
  34.     BegLine()
  35.     if PosFirstNonWhite() and PrevChar() and lFind("[~ \t\x00\xff]","xb")
  36.         text = GetText(1, PosFirstNonWhite() - 1)
  37.         PopPosition()
  38.         PushPosition()
  39.         BegLine()
  40.         DelChar(PosFirstNonWhite() - 1)
  41.         InsertText(text, _INSERT_)
  42.     endif
  43.     PopPosition()
  44.     GotoPos(p)
  45.     Down()
  46. end
  47.  
  48. // Shift text on the current line so as to be aligned with the cursor,
  49. // for instance, move the cursor to the desired column, press the key
  50. // this command is assigned to, and the text will be shifted such that
  51. // it lines up with the cursor.
  52. // After aligning the current line, the cursor moves to the next line.
  53. proc AlignAtCursor()
  54.     integer p = CurrPos()
  55.  
  56.     if PosFirstNonWhite()
  57.         ShiftText(CurrPos() - PosFirstNonWhite())
  58.     endif
  59.     GotoPos(p)
  60.     Down()
  61. end
  62.  
  63.